using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using  AndersLiu.Samples.EnumSimilarClass;

namespace TestInWindowsApplication
{
	public partial class MainForm : Form
	{
		public MainForm()
		{
			InitializeComponent();
		}

		/// <summary>
		/// Process a document with given type.
		/// </summary>
		/// <param name="doc">Type of the document.</param>
		private void process(DocumentType doc)
		{
			string msg = string.Format(
				"I'm working with a {0} document in {1}.",
				(string)doc, doc.Processor);  // Look, use it just like a normal object.

			MessageBox.Show(msg);
		}

		private void btnProcessWord_Click(object sender, EventArgs e)
		{
			process(DocumentType.Word);  // Look, it looks similarly an enum!
		}

		private void btnProcessHtml_Click(object sender, EventArgs e)
		{
			process(DocumentType.Html);
		}

		private void btnProcessText_Click(object sender, EventArgs e)
		{
			process(DocumentType.Text);
		}

		private void btnTest_Click(object sender, EventArgs e)
		{
			try
			{
				process((DocumentType)txtTypeName.Text);  // Used the explicit convertion.
			}
			catch(Exception ex)
			{
				MessageBox.Show("Exception!\r\n----------\r\n" + ex.Message);
			}
		}
	}
}